package com.netjava.service.impl;

import java.util.List;

import com.netjava.dao.IProductDAO;
import com.netjava.pojo.Product;
import com.netjava.service.IProductService;
/**
 * 商品的业务的实施类。
 * @author nana
 *
 */
public class ProductService implements IProductService {

	private IProductDAO productDao;
	public Product addProduct(Product product) {
		product.setState(0);
		productDao.save(product);
		return product;
	}

	public void delete(Product product) {
		productDao.delete(product);
	}

	public Product getProById(Integer id) {
		return productDao.findById(id);
	}

	public IProductDAO getProductDao() {
		return productDao;
	}

	public void setProductDao(IProductDAO productDao) {
		this.productDao = productDao;
	}
/**
 * 根据产品名字得到产品信息
 * param 产品名
 * return 产品对象列表
 */
	public List<Product> getProByName(String productName) {
		List<Product> proList=productDao.findByProductName(productName);
		return proList;
	}
	
	public void attachDirty(Product instance){
		productDao.attachDirty(instance);
	}

	public List<Product> pageCutGet(Integer state,Integer page,Integer num) {
		List<Product> list=productDao.pageCutSel(state,page,num);
		return list;
	}


}
